import Vue from 'vue';
import zhCN from '@/config/locale-zhCN';
import en from '@/config/locale-en';
import VueI18n from 'vue-i18n';
import urlUtils from '@/libs/urlutils';

// 加载国际化
Vue.use(VueI18n);

const messages = {
  zhCN: {
    ...zhCN
  },
  en: {
    ...en
  }
};
let locale = urlUtils.getParams('locale');
if (locale) {
  locale = locale.toLocaleLowerCase();
} else {
  const lang = window.navigator.language.toLowerCase();
  locale = lang === 'zh-cn' ? 'zh_cn' : 'en';
}

export default new VueI18n({
  locale: 'en',
  messages
});
